package com.life.view;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

import javax.swing.JComponent;

import com.life.utils.BoardLocationStruct;

public class MouseAdapter extends AbstractAdapter implements MouseMotionListener, MouseListener
{
    LifeCanvas theCanvas = null;
    boolean enabled = true;
    
    public MouseAdapter(LifeCanvas component)
    {
	theCanvas = component;
	theCanvas.addMouseListener(this);
	theCanvas.addMouseMotionListener(this);
    }
    
    
    @Override
    public Object get()
    {
	// TODO Auto-generated method stub
	return null;
    }

    @Override
    public void set(Object data)
    {
	// TODO Auto-generated method stub

    }

    @Override
    public void setEnabled(boolean value)
    {
	enabled = value;

    }


    public void mouseDragged(MouseEvent arg0)
    {
	// TODO Auto-generated method stub
	
    }


    public void mouseMoved(MouseEvent arg0)
    {
	if(enabled)
	{
	    BoardLocationStruct struct = theCanvas.getBoardLocation(arg0.getX(),arg0.getY());
	    setChanged();
	    notifyObservers(struct);
	}
	
	
    }


    public void mouseClicked(MouseEvent arg0)
    {
	// TODO Auto-generated method stub
	
    }


    public void mouseEntered(MouseEvent arg0)
    {
	if(enabled)
	{
	    BoardLocationStruct struct = theCanvas.getBoardLocation(arg0.getX(),arg0.getY());
	    setChanged();
	    notifyObservers(struct);
	}
	
    }


    public void mouseExited(MouseEvent arg0)
    {
	// TODO Auto-generated method stub
	
    }


    public void mousePressed(MouseEvent arg0)
    {
	// TODO Auto-generated method stub
	
    }


    public void mouseReleased(MouseEvent arg0)
    {
	// TODO Auto-generated method stub
	
    }

}
